package com.jubao.ejb.dao;

import java.io.Serializable;
import java.util.List;

import com.jubao.ejb.entity.GeneEntity;
import com.jubao.ejb.entity.GeneRelation;

public interface GeneRelationDao extends Serializable {

	/**
	 * save geneRelation
	 * 
	 * @param relation
	 * @return geneRelation
	 */
	public GeneRelation save(GeneRelation relation);

	/**
	 * Remove geneRelation
	 * 
	 * @param relation
	 */
	public void remove(GeneRelation relation);

	/**
	 * find GeneRelation
	 * 
	 * @param sysId GeneRelation sysId
	 * @return 
	 */
	public GeneRelation find(long sysId);

	/**
	 * find GeneRelation 
	 * 
	 * @param entitySysId from entity sysid
	 * @param relationId relation 
	 * @param entity2SysId to entity sysid
	 * @return
	 */
	public GeneRelation find(long entitySysId, int relationId, long entity2SysId);

	/**
	 * get count entity relations  between entity and entity2
	 * entity ------> entity2 
	 * 
	 * @param entitySysId
	 * @param relationId
	 * @param entity2SysId
	 * @return
	 */
	public long getRelationCount(long entitySysId, int relationId, long entity2SysId);

	/**
	 * get page of geneRelation between entity and entity2
	 * entity ------> entity2 
	 * 
	 * @param entitySysId
	 * @param relationId
	 * @param entity2SysId
	 * @param pgno
	 * @param pgsize
	 * @return
	 */
	public List<GeneRelation> getRelationList(long entitySysId, int relationId, long entity2SysId, int pgno, int pgsize);

	/**
	 * Get page of entities who has relation1 with entity1 and has relation2 with entity2,
	 * 
	 * based on actionType parameter:-
	 * 1. @see {@link com.jubao.ejb.dao.util.DaoConstant#GetEntity_XE1_XE2_XE3} 
	 * 			  +---> Entity1
	 * (EntityX)--|---> Entity2
	 *            +---> Entity3
	 * 
	 * @param entityName
	 * @param relationId1
	 * @param entity1SysId
	 * @param relationId2
	 * @param entity2SysId
	 * @param relationId3
	 * @param entity3SysId
	 * @param actionType
	 * @param pgno
	 * @param pgsize
	 * @return
	 */
	public List<GeneEntity> getEntityList(String entityName, int relationId1, long entity1SysId, int relationId2,
			long entity2SysId, int relationId3, long entity3SysId, int actionType, int pgno, int pgsize);

	/**
	 * Get Count of entities who have relation1 with entity1 and has relation2 with entity2 and has relation3 with entity3
	 * 
	 * @see {@link com.jubao.ejb.dao.GeneRelationDao#getEntityList}
	 *  
	 * @param entityName
	 * @param relationId1
	 * @param entity1SysId
	 * @param relationId2
	 * @param entity2SysId
	 * @param relationId3
	 * @param entity3SysId
	 * @param actionType
	 * @return
	 */
	public long getEntityCount(String entityName, int relationId1, long entity1SysId, int relationId2,
			long entity2SysId, int relationId3, long entity3SysId, int actionType);

	/**
	 * Get page of entities who has relation1 with entity1 and has relation2 with entity2
	 * 
	 * based on actionType parameter:-
	 * 1. @see {@link com.jubao.ejb.dao.util.DaoConstant#GetEntity_XE1_XE2_XE3} 
	 * 			  +---> Entity1
	 * (EntityX)--|
	 *            +---> Entity2
	 * 
	 * @param entityName
	 * @param relationId1
	 * @param entity1SysId
	 * @param relationId2
	 * @param entity2SysId
	 * @param pgno
	 * @param pgsize
	 * @return
	 */
	public List<GeneEntity> getEntityList(String entityName, int relationId1, long entity1SysId, int relationId2,
			long entity2SysId, int pgno, int pgsize);

	/**
	 * Get Count of entities who have relation1 with entity1 and has relation2 with entity2
	 * 
	 * @see {@link com.jubao.ejb.dao.GeneRelationDao#getEntityList}
	 * 
	 * @param entityName
	 * @param relationId1
	 * @param entity1SysId
	 * @param relationId2
	 * @param entity2SysId
	 * @return
	 */
	public long getEntityCount(String entityName, int relationId1, long entity1SysId, int relationId2, long entity2SysId);

	/**
	 * Get page of entities who has relation1 with entity1
	 * 			  
	 * (EntityX)--+---> Entity1
	 * 
	 * @param entityName
	 * @param relationId1
	 * @param entity1SysId
	 * @param pgno
	 * @param pgsize
	 * @return
	 */
	public List<GeneEntity> getEntityList(String entityName, int relationId1, long entity1SysId, int pgno, int pgsize);

	/**
	 * Get Count of entities who have relation1 with entity1
	 * 
	 * @see {@link com.jubao.ejb.dao.GeneRelationDao#getEntityList}
	 * 
	 * @param entityName
	 * @param relationId1
	 * @param entity1SysId
	 * @return
	 */
	public long getEntityCount(String entityName, int relationId1, long entity1SysId);

	/**
	 * Get list of entities who have relation1 start from entity1
	 * 
	 * @param entity1SysId
	 * @param relationId1
	 * @param entity2SysId
	 * @param entity2Name
	 * @param pgno
	 * @param pgsize
	 * @return
	 */
	public List<GeneEntity> getEntity2List(long entity1SysId,int relationId1, long entity2SysId,String entity2Name,  int pgno, int pgsize);
	
	/**
	 * Get count of entities who have relation1 start from entity1
	 * 
	 * @param entity1SysId
	 * @param relationId1
	 * @param entity2SysId
	 * @param entity2Name
	 * @return
	 */
	public long getEntity2Count(long entity1SysId,int relationId1, long entity2SysId,String entity2Name );
}
